package com.gz.utils;

import java.io.*;

public class WebUtils {
    public static int parseInt(String strnum,int defaultVal) {
        try {
            return Integer.parseInt(strnum);
        } catch (NumberFormatException e) {
            System.out.println("不能转成数字");
        }
        return defaultVal;
    }

    public static boolean isHtml(String uri){
        return uri.endsWith(".html");
    }

    public static String readHtml(String filename){
        //内路径
        String path = WebUtils.class.getResource("/").getFile();
        StringBuilder stringBuilder = new StringBuilder();
        try {
            BufferedReader bufferedReader = new BufferedReader(
                    new FileReader(path + filename));
            String buf="";
            while((buf=bufferedReader.readLine())!=null){
                stringBuilder.append(buf);
            }        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return stringBuilder.toString();

    }
}
